package com.example.dome;

import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.driver.api.ShardingSphereDataSourceFactory;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
import org.apache.shardingsphere.spring.boot.ShardingSphereAutoConfiguration;
import org.apache.shardingsphere.spring.boot.prop.SpringBootPropertiesConfiguration;
import org.apache.shardingsphere.spring.boot.rule.LocalRulesCondition;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Primary;
import org.springframework.core.env.Environment;

import javax.sql.DataSource;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.sql.SQLException;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Optional;


/**
 * @author Administrator
 */
@MapperScan(basePackages = "com.example.**.mapper")
@SpringBootApplication(scanBasePackages = {"com.example.dome"})
@Slf4j
public class DomeApplication extends ShardingSphereAutoConfiguration {

    public DomeApplication(SpringBootPropertiesConfiguration props) {
        super(props);
    }

    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext application = SpringApplication.run(DomeApplication.class, args);
        System.out.println("项目启动成功 *^_^* \n"
                + " .-------.       ____     __        \n"
                + " |  _ _   \\      \\   \\   /  /    \n"
                + " | ( ' )  |       \\  _. /  '       \n"
                + " |(_ o _) /        _( )_ .'         \n"
                + " | (_,_).' __  ___(_ o _)'          \n"
                + " |  |\\ \\  |  ||   |(_,_)'         \n"
                + " |  | \\ `'   /|   `-'  /           \n"
                + " |  |  \\    /  \\      /           \n"
                + " ''-'   `'-'    `-..-'              ");
        Environment env = application.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String path = env.getProperty("server.servlet.context-path");
        if (StrUtil.isEmpty(path)) {
            path = "";
        }
        log.info("\n----------------------------------------------------------\n\t"
                + "Application  is running! Access URLs:\n\t"
                + "Local访问网址: \t\thttp://localhost:" + port + path + "\n\t"
                + "External访问网址: \thttp://" + ip + ":" + port + path + "\n\t"
                + "Swagger访问网址: \thttp://" + ip + ":" + port + "/doc.html" + "\n\t"
                + "----------------------------------------------------------");
    }



}
